<%@ page language="java" import="java.util.*,com.ncp.model.entity.news.*,com.ncp.model.biz.news.*,com.ncp.model.dao.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//ArrayList al=new NewsManager().getAllNews();
ArrayList al;
DB db = new DB();
int PageNow=1;
int pageSize=16;
db.setSql("select count(*) from NEWS");
int PageCount = db.getPageCount(pageSize);
String S_PageNow = (String)request.getAttribute("pageNow");
if(S_PageNow==null){
	
 al=new NewsManager().fenYe(pageSize,1);
}
else {
	PageNow=Integer.parseInt(S_PageNow);
	 al=new NewsManager().fenYe(pageSize,PageNow);
	
}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'news.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link href="css/common.css" type="text/css" rel="stylesheet" />
<style type="text/css">

*{ padding:0; margin:0; border:0; font-size:12px; color:#6F7C82;}

#news{ width:724px; margin:10px auto; border:1px solid #ddd;} 

#news .title_4{ width:724px; height:30px; background:url(images/title_4.png) no-repeat;}

#news .content_4{ padding:20px 30px;}

#news .content_4 ul li{ list-style:none; background:url(images/icon_5.png) no-repeat; padding-left:20px; line-height:30px; border-bottom:1px dashed #DDD;}

.left{ float:left;}

a{  text-decoration:none;}

#news .content_4 ul li a:hover{ color:#999; text-decoration:underline;}

#page{ height:30px; padding-top:10px;}

#page a{ padding-left:20px;}

#page a:hover{ text-decoration:underline; color:#C33;}

</style>
  </head>
  
  <body>
   <div id="allpage">
	
		<jsp:include flush="true" page="../index/head.jsp"></jsp:include>
		
		<div id="main" style="padding:0px; width:760px;">
		
		
		
			<%--<div style=" padding:20px 0;">
			
			<%
   for(int i=0;i<al.size();i++){
   		NewsBean nb=(NewsBean)al.get(i);
   	%>
   	<span class="right"><%=nb.getpDate() %></span><a class="list_news left" href="NewsClServlet?type=content&id=<%=nb.getId()%>"><%=i+1 %>:<%=nb.getTitle() %></a>
   	<br style="clear:both;"/>
   	<%
   }
   %>
			
			</div>
			
   
		--%>
		<div id="news">

		<div class="title_4"></div>

		<div class="content_4">

			<ul>
				 <%
				 for(int i=0;i<al.size();i++){
				 		NewsBean nb=(NewsBean)al.get(i);
				 	%>
				<li><span class="left"><%=nb.getpDate() %>&nbsp;&nbsp;&nbsp;&nbsp;</span><a class="left" href="NewsClServlet?type=content&id=<%=nb.getId()%>"><%=nb.getTitle() %></a><div style="clear:both"></div></li>

				<%
				 }
				
				%>
				

			</ul>

		</div>

		<div id="page">
           <%
           if(PageCount!=1){
           %>
			<p>

				<a class="left" href="NewsClServlet?type=pages&pageNow=1">[首页]</a>
				<%
				if(PageNow>1){
				%>
				<a class="left" href="NewsClServlet?type=pages&pageNow=<%=PageNow-1 %>">[上一页]</a>
				<%} %>
               <%for(int i=PageNow;i<PageNow+5&&i<PageCount;i++){ %>
               
				<a class="left" href="NewsClServlet?type=pages&pageNow=<%=i %>"><%=i %></a>
              <%} %>
           <%
				if(PageNow<PageCount){
				%>
				<a class="left" href="NewsClServlet?type=pages&pageNow=<%=PageNow+1 %>">[下一页]</a>
				<%} %>
				<%
				if(PageNow!=PageCount){
				%>
				<a class="left" href="NewsClServlet?type=pages&pageNow=<%=PageCount %>">[尾页]</a>
                <%} %>

			</p>
<%} %>
		</div>

	</div>


		
		</div>
		<div id="slice"></div>
	
	<jsp:include flush="true" page="../index/foot.jsp"></jsp:include>
	</div>
  </body>
</html>
